"""

"""
from socket import *


def handle(conn):
    request=conn.recv(1024)
    with open("../day16/doudou.jpeg", "wb") as fr:
        data=fr.read()
    response = "HTTP/1.1 200 OK\r\n"
    response += "content-type:image/jpeg\r\n"
    response += "\r\n"
    response = response.encode() + data
    conn.send(response)


def main():
    sock = socket()
    sock.bind(("0.0.0.0",8000))
    sock.listen(5)
    while True:
    #　等待浏览器连接
        conn,addr = sock.accept()
        print("Connect from",addr)
        handle(conn)
        conn.close()

if __name__ == '__main__':
    main()